package com.example.msdksample;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    private TextView logTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        logTextView = findViewById(R.id.logTextView);

        // 设置 MyApplication 的日志回调
        MyApplication myApp = (MyApplication) getApplication();
        myApp.setLogCallback(new MyApplication.LogCallback() {
            @Override
            public void onLogReceived(String logMessage) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        // 追加日志到 TextView
                        String currentText = logTextView.getText().toString();
                        logTextView.setText(currentText + logMessage + "\n");
                    }
                });
            }
        });
    }
}